<?php
class BreakcrumbWidget extends CWidget
{	
	var $data = NULL;
	var $action = NULL;
	
	public function init()
	{
		// this method is called by CController::beginWidget()
		$this->data = array();
		//$this->action = "";
	}
	
	public function run()
	{
		// this method is called by CController::endWidget()
		$adminmenu_id = $this->getController()->session["adminmenu_id"];
		
		$str = "";
		$str .= CHtml::image(
			Yii::app()->baseUrl."/assets/icon/icon_break.png"
		);
		$str .= "Home";
		$this->data["image"] = "icon-48-home.png";
		
		$adminmenu = adminmenu::model()->findByPk($adminmenu_id);
		if (!is_null($adminmenu))
		{
			$this->data["image"] = $adminmenu->image;
			
			$str = "";
			$str .= CHtml::image(Yii::app()->baseUrl."/assets/icon/icon_break.png");
			$str .= $adminmenu->name;
			if (strlen($this->action) > 0)
			{
				$str .= CHtml::image(Yii::app()->baseUrl."/assets/icon/icon_break.png");
				$str .= $this->action;
			}
		}
		
		$this->data["str"] = $str;

		$this->render("breakcrumb", $this->data);
	}
}